import React from 'react';
import { connect } from 'umi';
import { Table } from 'antd';
import { tableLocale } from '@/tool/components/PageEmpty';

import styles from './index.less';

const { Column } = Table;

export const CentralizedTable = (props) => {
  return (
    <Table
      className={styles.CentralizedTable}
      dataSource={props.centralizedTableData}
      locale={tableLocale}
      pagination={false}
      bordered={true}
      rowKey="timeOrder"
    >
      <Column align="center" title="时点" dataIndex="timeOrder" key="timeOrder" width={100} />
      <Column
        align="center"
        title="成交电量(日均)"
        dataIndex="averageClearingPower"
        key="averageClearingPower"
        width={100}
        render={(text) => text.toFixed(3)}
      />
      <Column
        align="center"
        title="买方申报电量(日均)"
        dataIndex="purchaserPower"
        key="purchaserPower"
        width={100}
        render={(text) => text.toFixed(3)}
      />
      <Column
        align="center"
        title="卖方申报电量(日均)"
        dataIndex="sellerPower"
        key="sellerPower"
        width={100}
        render={(text) => text.toFixed(3)}
      />
      <Column
        align="center"
        title="边际买方申报电量(日均)"
        dataIndex="purchaserMarginalPower"
        key="purchaserMarginalPower"
        width={100}
        render={(text) => text.toFixed(3)}
      />
      <Column
        align="center"
        title="边际卖方申报电量(日均)"
        dataIndex="sellerMarginalPower"
        key="sellerMarginalPower"
        width={100}
        render={(text) => text.toFixed(3)}
      />
      <Column
        align="center"
        title="边际价格"
        dataIndex="marginalPrice"
        key="marginalPrice"
        width={100}
        render={(text) => text.toFixed(2)}
      />
      <Column
        align="center"
        title="边际买方申报电价"
        dataIndex="purchaserMarginalPrice"
        key="purchaserMarginalPrice"
        width={100}
        render={(text) => text.toFixed(2)}
      />
      <Column
        align="center"
        title="边际卖方申报电价"
        dataIndex="sellerMarginalPrice"
        key="sellerMarginalPrice"
        width={100}
        render={(text) => text.toFixed(2)}
      />
    </Table>
  );
};

const mapStateToProps = ({ mediumAndLongTermMarket }) => ({
  centralizedTableData: mediumAndLongTermMarket.centralizedTableData,
});

const mapDispatchToProps = {};

export default connect(mapStateToProps, mapDispatchToProps)(CentralizedTable);
